﻿<%@ WebHandler Language="C#" Class="CheckUser" %>

using System;
using System.Web;
using System.Data.SqlClient;
using PM.Code.DAL;

public class CheckUser : IHttpHandler 
{
    
        public void ProcessRequest (HttpContext context)
        {
            PM.PMSys.account aaccount = new PM.PMSys.account();
            context.Response.ContentType = "text/plain";
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            context.Response.Expires = -1;
            context.Response.AddHeader("Pragma", "No-Cache");
            string UserName = context.Request["userName"];
            if (UserName != null&&UserName.Length>3)
            {
                if (UserName.IndexOf("@") > -1 || UserName.IndexOf("#") > -1 || UserName.IndexOf(".") > -1 || UserName.IndexOf("*") > -1)
                {
                    context.Response.Write("您注册的帐号名称，含有特殊字符或已被过滤，请修改！");
                    context.Response.End();
                }
                else
                {
                    int s = aaccount.CheckUser(UserName);
                    if (s==0)
                    {
                        context.Response.Write("yes");
                        context.Response.End();
                    }
                    else
                    {
                        context.Response.Write("no");
                        context.Response.End();
                    }
                }
            }
            //else
            //{
            //    context.Response.Write("检测过程中，出现错误，请重试！");
            //    context.Response.End();
            //}
        }
    public bool IsReusable
   {
        get 
        {
            return false;
        }
    }

}